Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inventory: Implement aggregation of multiple variable values #408

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

tupyy
Copy link
Contributor

@tupyy tupyy commented Oct 1, 2024

This PR fixes the aggregation of multiple host variable values.

Let's say SNow returns something like this:

{'u_name': 'First_app', 'u_parent': 'tomcat_aqwidmvs', 'sys_id': 'a7dc8d0633a8d210392d0e570e5c7bb4', 'u_child': 'i101', 'u_level': '1', 'u_child.name': 'i101', 'u_child.ip_address': '10.1.0.101', 'u_parent.support_group': 'Application Development', 'u_parent.name': 'tomcat_aqwidmvs'}
{'u_name': 'Second app', 'u_parent': 'tomcat_pxgnodig', 'sys_id': 'f9fc8d0633a8d210392d0e570e5c7bff', 'u_child': 'i101', 'u_level': '1', 'u_child.name': 'i101', 'u_child.ip_address': '10.1.0.101', 'u_parent.support_group': 'Application Development', 'u_parent.name': 'tomcat_pxgnodig'}

For the same host, we have two records with different values: u_parent, u_parent.name, u_parent.support_group, u_parent.name.

This change will aggregate these values as follows:

all:
  children:
    ungrouped:
      hosts:
        i101:
          sys_id: a7dc8d0633a8d210392d0e570e5c7bb4
          u_child:
          - ip_address: 10.1.0.101
            name: i101
          u_level: '1'
          u_parent:
          - name: tomcat_aqwidmvs
            support_group: Application Development
            u_parent: tomcat_aqwidmvs
          - name: tomcat_pxgnodig
            support_group: Application Development
            u_parent: tomcat_pxgnodig
          u_type: active

To enable this aggregation, the inventory must have:

experimental_aggregation: true

@tupyy tupyy force-pushed the support-lists-sourced-from-columns branch from 0db1e4c to 3d7e94b Compare October 1, 2024 15:00
Copy link

plugins/inventory/now.py Outdated Show resolved Hide resolved
plugins/inventory/now.py Outdated Show resolved Hide resolved
tests/unit/plugins/inventory/test_now.py Show resolved Hide resolved
@tupyy tupyy force-pushed the support-lists-sourced-from-columns branch 2 times, most recently from 423e008 to 5222258 Compare October 3, 2024 14:39
Copy link

This commit fixes the aggregation of multiple host variables values.
Let's say SNow returns something like this:
```
{'u_name': 'First_app', 'u_parent': 'tomcat_aqwidmvs', 'sys_id': 'a7dc8d0633a8d210392d0e570e5c7bb4', 'u_child': 'i101', 'u_level': '1', 'u_child.name': 'i101', 'u_child.ip_address': '10.1.0.101', 'u_parent.support_group': 'Application Development', 'u_parent.name': 'tomcat_aqwidmvs'}
{'u_name': 'Second app', 'u_parent': 'tomcat_pxgnodig', 'sys_id': 'f9fc8d0633a8d210392d0e570e5c7bff', 'u_child': 'i101', 'u_level': '1', 'u_child.name': 'i101', 'u_child.ip_address': '10.1.0.101', 'u_parent.support_group': 'Application Development', 'u_parent.name': 'tomcat_pxgnodig'}
```
For the same host, we have two records with different values: u_parent,
u_parent.name, u_parent.support_group, u_parent.name.

This change will aggreate these values as follows:
```
all:
  children:
    ungrouped:
      hosts:
        i101:
          sys_id: a7dc8d0633a8d210392d0e570e5c7bb4
          u_child:
          - ip_address: 10.1.0.101
            name: i101
          u_level: '1'
          u_parent:
          - name: tomcat_aqwidmvs
            support_group: Application Development
            u_parent: tomcat_aqwidmvs
          - name: tomcat_pxgnodig
            support_group: Application Development
            u_parent: tomcat_pxgnodig
          u_type: active
```

To enable this aggregation, the inventory must have:
```
experimental_aggregation: true
```
@tupyy tupyy force-pushed the support-lists-sourced-from-columns branch from 5222258 to e119c66 Compare October 3, 2024 14:56
Copy link

Copy link

@mhjacks mhjacks merged commit ec8b621 into main Oct 3, 2024
72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants